"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.utilTemplate = void 0;
var UtilTemplate = /** @class */ (function () {
    function UtilTemplate() {
        /** 变量定义 */
        this.varTemp = "\n\t\t/** {desc} */\n\t\t{varName} : {varType};";
        /** 接口定义 */
        this.interfaceTemp = "\t/** {desc} */\n\tinterface {name} {\n{varList} \n\t}\n";
        this.nsTemp = 'declare namespace msg.auto {\n';
    }
    /**
     * 拼接变量字符串
     * @param varList 变量数据列表
     * @returns
     */
    UtilTemplate.prototype.genVarStr = function (varList) {
        var _this = this;
        if (varList && varList.length > 0) {
            var str = '';
            var list_1 = [];
            varList.forEach(function (item) {
                var line = _this.varTemp.replace('{varName}', item.name);
                line = line.replace('{varType}', item.type);
                line = line.replace('{desc}', item.description);
                list_1.push(line);
            });
            if (list_1.length > 0) {
                str = list_1.join('\n');
                return str;
            }
        }
        return '';
    };
    UtilTemplate.prototype.genInterface = function (map) {
        var str = '';
        var tag = '';
        for (var key in map) {
            var item = map[key];
            var varStr = this.genVarStr(item.varList);
            var interfaceStr = this.interfaceTemp.replace('{desc}', item.desc);
            if (item.tags) {
                if (tag != item.tags) {
                    tag = item.tags;
                    interfaceStr = '//MARK: ' + tag + '\n' + interfaceStr;
                }
            }
            var n = item.name;
            if (item.nameTail) {
                n += item.nameTail;
            }
            interfaceStr = interfaceStr.replace('{name}', n);
            interfaceStr = interfaceStr.replace('{varList}', varStr);
            str += interfaceStr;
        }
        str = this.nsTemp + str + '\n}';
        return str;
    };
    return UtilTemplate;
}());
exports.utilTemplate = new UtilTemplate();
